package com.stars.Test.controller;

import com.stars.base.entity.Result;
import com.stars.util.cache.CacheUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Rocks
 * @version : 1.0
 * @date : 2022/11/19 19:03
 * @description : redis测试
 */
@RestController
@RequestMapping("/test/redis")
public class TestRedisController {

    private final CacheUtil cacheUtil;

    public TestRedisController(CacheUtil cacheUtil) {
        this.cacheUtil = cacheUtil;
    }

    @RequestMapping("getValueByKey")
    public Result getValueByKey(String key){
        return Result.success(cacheUtil.getValue(key));
    }

    @RequestMapping("/setValue")
    public Result setValue(String key,String value){
        return Result.result(cacheUtil.setValue(key,value));
    }

    @RequestMapping("/removeKey")
    public Result removeKey(String key){
        cacheUtil.delKey(key);
        return Result.success();
    }

}
